{extend name="ashippingguide/Public/base" /}
{block name="container"}
<style>
    .textEff {
        background-color: #efffff;
    }

    .checkbox-inline input[type=checkbox], .radio-inline input[type=radio] {
        margin-top: 2px;
    }
</style>
<script>
    $(function () {
        $('#uploadify').uploadifive({
            'buttonText': '附件',
            'width': '50px',
            'height': '30px',
            'fileObjName': "bx_fy2",
            'queueID': "uploadifyQueue",
            'queueSizeLimit': 15,//这里我只允许单个图片上传
            'uploadScript': '{:url("ashippingmanagement2/uploadifive")}',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.success) {
                    var dataValue = JSON.stringify(data.data);
                    file.queueItem.attr('uri', dataValue);
                } else {
                    file.queueItem.addClass('error');
                    file.queueItem.find('.fileinfo').html('-' + data.message);
                }
            }
        });
    })
</script>
<div class="page-heade">
    <h2 class="title_color text-center">添加导购入职申请</h2>
</div>
<div class="bs-docs-container" id="main">
    <div class="">
        <div class="col-md-12" role="main" style="padding: 4px">
            <div class="bs-docs-section">
                <form id="form_id" action="{:url('ashippingguide/addentryapple')}" class="form-inline" method="post"
                      enctype='multipart/form-data'>
                    <table class="table-bordered table row-margin-top" style="margin-bottom: 0">
                        <tr>
                            <td class="text-center">申请人<span class="colorRed">*</span></td>
                            <input type="hidden" name="applicant" value="{$user}" id="applicant">
                            <td>{$user}</td>
                            <td class="text-center">填写时间</td>
                            <input type="hidden" name="fillintime" value='{:date("Y-m-d H:i:s")}' id="fillintime">
                            <td class="text-left" id="applytime" colspan="4">{:date("Y-m-d H:i:s")}</td>
                        </tr>
                        <tr>
                            <td colspan="7" class="info font-bold text-center">导购基本信息</td>
                        </tr>
                        <tr>
                            <td class="text-center" style="min-width: 130px;width: 130px">姓名<span
                                    class="colorRed">*</span></td>
                            <td><input type="text" class="form-control validate[required,ajax[name]]" id="name"
                                       name="name" size="16" value=""><span
                                    class="fa fa-question colorRed lr_5" title='姓名不能重复' style="font-size: 18px"></span>
                            </td>
                            <td class="text-center" style="min-width: 130px;width: 130px">工牌号<span
                                    class="colorRed">*</span></td>
                            <td><input type="text" class="form-control validate[required]" size="16" name="workNumber"
                                       value="" id="workNumber"></td>
                            <td class="text-center" style="min-width: 130px;width: 130px">性别<span
                                    class="colorRed">*</span></td>
                            <td>
                                <label for="man">
                                    <input type="radio" name="sex" id="man" value="0" checked>男
                                </label>
                                <label for="woman">
                                    <input type="radio" name="sex" id="woman" value="1">女
                                </label>
                            </td>
                            <td class="text-center" rowspan="5" style="width: 180px">
                                <div style="width: 80%;height: 120px" class="form-group text-center">
                                    <a id="personPicA" rel="example_group1" href="javascript:void(0);">
                                        <label for="userPhoto">
                                            <img id="userPhoto_img" class="thumb" alt="个人近照"
                                                 src="__STATIC__/layout/img/nopic_boy.gif"
                                                 height="130" width="100"/></label></a>
                                    <input type="file" value="" class="upLoad" name="userPhoto" id="userPhoto"
                                           style="display: none;">
                                </div>
                                <div class="text-center" style="margin-top: 20px">
                                    <a href="javascript:void (0)">一寸免冠照片上传</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">身份证号码<span class="colorRed">*</span></td>
                            <td><input type="text" class="form-control validate[required,custom[chinaId]]" size="23"
                                       value="" name="IDNo"></td>
                            <td class="text-center">出生日期<span class="colorRed">*</span></td>
                            <td><input type="text" class="layer-date form-control date" name="birthDate" id="birthDate"
                                       value=""></td>
                            <td class="text-center">民族</td>
                            <td><input type="text" class="form-control validate[custom[chinese]]" name="nation"
                                       id="nation" value=""></td>
                        </tr>
                        <tr>
                            <td class="text-center">用户名</td>
                            <td><input type="text" class="form-control" id="user" name="user" size="16" value=""><span
                                    class="fa fa-question colorRed lr_5" title='用户名不能重复' style="font-size: 18px"></span>
                            </td>
                            <td class="text-center">密码</td>
                            <td><input type="text" class="form-control" id="password" name="password" size="16"
                                       value=""><span
                                    class="fa fa-question colorRed lr_5" title='密码不能重复' style="font-size: 18px"></span>
                            </td>
                            <td class="text-center">角色<span class="colorRed">*</span></td>
                            <td>
                                <select name="role" id="role" class="form-control select">
                                    <option value="">请选择</option>
                                    <option value="导购员">导购员</option>
                                    <option value="导购主管">导购主管</option>
                                    <option value="导购负责人">导购负责人</option>
                                    <option value="测试2">测试2</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">所属主网点<span class="colorRed">*</span></td>
                            <td>
                                <div class="col-xs-8">
                                    <div class="input-group">
                                        <input type="text" class="form-control validate[required]" value=""
                                               name="mainNet"
                                               id="mainNet" onfocus="net('mainNet')"
                                               placeholder="请输入关键字或空格查询">
                                        <div class="input-group-btn">
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" name="mainNet_id" id="mainNet_id" value="">
                                <div class="col-xs-2">
                                    <input type="button" class="btn btn-primary" id="select_mainNet"
                                           onclick="netTree('mainNet')" value="选择"/>
                                </div>
                            </td>
                            <td class="text-center">所属网点<br><span class="colorRed">(最多选择50个网点)</span></td>
                            <td colspan="3">
                                <div class="row">
                                    <div class="col-xs-6">
                                        <div class="input-group">
                                            <input type="text" class="form-control" value="" name="otherNet"
                                                   id="otherNet" onfocus="net('otherNet')"
                                                   placeholder="请输入关键字或空格查询">
                                            <div class="input-group-btn">
                                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                    <input type="hidden" name="otherNet_id" id="otherNet_id" value="">
                                    <div class="col-xs-2">
                                        <input type="button" class="btn btn-primary" id="select_otherNet"
                                               onclick="netTree('otherNet')" value="选择"/>
                                    </div>
                                    <div class="col-xs-4"></div>
                                </div>
                                <div class="duoxuan" id="selected_net"></div>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">所属品牌</td>
                            <td colspan="5">
                                <div class="col-xs-8">
                                    <div class="input-group">
                                        <input type="text" class="form-control" value="" name="pinpai"
                                               id="pinpai"
                                               placeholder="请输入关键字或空格查询">
                                        <div class="input-group-btn">
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" name="pinpai_id" id="pinpai_id" value="">
                                <div class="col-xs-2">
                                    <input type="button" class="btn btn-primary" id="select_pinpai" value="选择"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">所属品类</td>
                            <td colspan="6">
                                <div class="col-xs-8">
                                    <div class="input-group">
                                        <input type="text" class="form-control" value="" name="pinlei"
                                               id="pinlei"
                                               placeholder="请输入关键字或空格查询">
                                        <div class="input-group-btn">
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" name="pinlei_id" id="pinlei_id" value="">
                                <div class="col-xs-2">
                                    <input type="button" class="btn btn-primary" id="select_pinlei" value="选择"/>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <table class="table-bordered table">
                        <tr>
                            <td colspan="7" class="font-bold info text-center" style="font-size:16px">导购岗位及联系信息</td>
                        </tr>
                        <tr>
                            <td class="text-center">入职时间<span class="colorRed">*</span></td>
                            <td><input type="text" class="form-control layer-date validate[required,custom[date]] date"
                                       name="entryDate" value="" id="entryDate"></td>
                            <td class="text-center">转正时间</td>
                            <td><input type="text" class="form-control layer-date validate[custom[date]] date"
                                       name="justDate" id="justDate" value=""></td>
                            <td class="text-center">离职时间</td>
                            <td colspan="2"><input type="text"
                                                   class="form-control layer-date validate[custom[date]] date"
                                                   name="quitDate"
                                                   id="quitDate" value=""><span
                                    class="fa fa-question colorRed lr_5" title='离职时间不能重复'
                                    style="font-size: 18px"></span></td>
                        </tr>
                        <tr>
                            <td class="text-center">岗位类型<span class="colorRed">*</span></td>
                            <td>
                                <select name="postType" id="postType" class="form-control select validate[required]">
                                    <option value="">请选择</option>
                                    <option value="0">全职</option>
                                    <option value="1">兼职</option>
                                    <option value="2">专职</option>
                                </select>
                            </td>
                            <td class="text-center">导购等级</td>
                            <td>
                                <select name="guideGrade" id="guideGrade" class="form-control select">
                                    <option value="">请选择</option>
                                    <option value="0" selected>金牌导购</option>
                                    <option value="1">银牌导购</option>
                                    <option value="2">普通导购</option>
                                </select>
                            </td>
                            <td class="text-center">促销员类型</td>
                            <td colspan="2">
                                <label for="cpromoters">
                                    <input type="radio" name="promoters" value="0" id="cpromoters" checked>长期促销员
                                </label>
                                <label for="lpromoters">
                                    <input type="radio" name="promoters" value="1" id="lpromoters">临时促销员
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">手机号<span class="colorRed">*</span></td>
                            <td><input type="text" class="form-control validate[required,custom[phone]]" id="phone"
                                       name="phone"
                                       value=""></td>
                            <td class="text-center">微信号</td>
                            <td><input type="text" class="form-control" id="weixin" name="weixin" value=""></td>
                            <td class="text-center">邮箱</td>
                            <td><input type="text" class="form-control validate[custom[email]]" id="email"
                                       name="email"></td>
                        </tr>
                        <tr>
                            <td class="text-center">是否签订合同<span class="colorRed">*</span></td>
                            <td>
                                <label for="signContract1">
                                    <input type="radio" id="signContract1" name="signContract" value="1">是
                                </label>
                                <label for="signContract0">
                                    <input type="radio" id="signContract0" name="signContract" value="0" checked>否
                                </label>
                            </td>
                            <td class="text-center">招聘渠道</td>
                            <td><input type="text" class="form-control" id="recruitmentChannels" value=""
                                       name="recruitmentChannels"></td>
                            <td class="text-center">招聘推荐人</td>
                            <td colspan="2">
                                <div class="col-xs-4">
                                    <div class="input-group">
                                        <input type="text" class="form-control" value="" name="referee" id="referee"
                                               placeholder="请输入关键字或空格查询">
                                        <div class="input-group-btn">
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" name="referee_id" id="referee_id" value="">
                                <div class="col-xs-2">
                                    <input type="button" class="btn btn-primary" id="selectreferee" value="选择"/>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <table class="table-bordered table text-center" style="margin-bottom: 0">
                        <tr>
                            <td class="info font-bold text-center"><a href="javascript:;" style="font-size: 16px"
                                                                      id="moreinfo">更多联系信息</a>
                            </td>
                        </tr>
                    </table>
                    <table class="table-bordered table" id="moreinfoDiv" style="display: none;margin-bottom: 0">
                        <tr>
                            <td class="text-center">现居住地址</td>
                            <td colspan="6">
                                <div class="form-group" style="padding: 2px">
                                    省：
                                    <select name="livingProvince" id="livingProvince" class="form-control select">
                                        <!--<option value="">&#45;&#45;请选择省份&#45;&#45;</option>-->
                                    </select>
                                    市：
                                    <select name="livingCity" id="livingCity" class="form-control select">
                                        <!--<option value="">&#45;&#45;请选择城市&#45;&#45;</option>-->
                                    </select>
                                    县或区：
                                    <select name="livingCounty" id="livingCounty" class="form-control select">
                                        <!--<option value="">&#45;&#45;请选择地区&#45;&#45;</option>-->
                                    </select>
                                    <script type="text/javascript">
                                        addressInit('livingProvince', 'livingCity', 'livingCounty');

                                        function living() {
                                            if ($('#houseAddress').val() == '') {
                                                sweetAlert("", "请完善户籍地址！", "error");
                                            } else {
                                                addressInit('livingProvince', 'livingCity', 'livingCounty', $('#houseProvince').val(), $('#houseCity').val(), $('#houseCounty').val());
                                                $('#livingAddress').val($('#houseAddress').val());
                                            }
                                        }
                                    </script>
                                </div>
                                <br>
                                详细地址：<input type="text" class="form-control" name="livingAddress" id="livingAddress"
                                            style="width: 50%">&nbsp;<button
                                    class="btn btn-sm btn-info" type="button" onclick="living()">同户籍地址
                            </button>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">户籍地址</td>
                            <td colspan="3">
                                <div class="form-group" style="padding: 2px">
                                    省：
                                    <select name="houseProvince" id="houseProvince" class="form-control select">
                                        <!--<option value="">&#45;&#45;请选择省份&#45;&#45;</option>-->
                                    </select>
                                    市：
                                    <select name="houseCity" id="houseCity" class="form-control select">
                                        <!--<option value="">&#45;&#45;请选择城市&#45;&#45;</option>-->
                                    </select>
                                    县或区：
                                    <select name="houseCounty" id="houseCounty" class="form-control select">
                                        <!--<option value="">&#45;&#45;请选择地区&#45;&#45;</option>-->
                                    </select>&nbsp;<button class="btn btn-sm btn-info" type="button" onclick="house()">
                                    同现居住地址
                                </button>
                                    <script type="text/javascript">
                                        addressInit('houseProvince', 'houseCity', 'houseCounty');

                                        function house() {
                                            if ($('#livingAddress').val() == '') {
                                                sweetAlert("", "请完善现居住地址！", "error");
                                            } else {
                                                addressInit('houseProvince', 'houseCity', 'houseCounty', $('#livingProvince').val(), $('#livingCity').val(), $('#livingCounty').val());
                                                $('#houseAddress').val($('#livingAddress').val());
                                            }
                                        }
                                    </script>
                                </div>
                                <br>
                                详细地址：<input type="text" class="form-control" value="" name="houseAddress"
                                            id="houseAddress" style="width: 60%">
                            </td>
                            <td class="text-center">户口性质</td>
                            <td colspan="2">
                                <select name="houseType" id="houseType" class="form-control select">
                                    <option value="">请选择</option>
                                    <option value="0">农村户口</option>
                                    <option value="1">城镇户口</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">紧急联系人</td>
                            <td><input type="text" class="form-control" id="urgentLinkman" value=""
                                       name="urgentLinkman"></td>
                            <td class="text-center">紧急联系人电话</td>
                            <td><input type="text" class="form-control validate[custom[phone]]" id="urgentTel" value=""
                                       name="urgentTel"></td>
                            <td class="text-center">与导购员关系</td>
                            <td colspan="2"><input type="text" class="form-control" id="guideRelationship" value=""
                                                   name="guideRelationship"></td>
                        </tr>
                    </table>
                    <table class="table-bordered table text-center" style="margin-bottom: 0">
                        <tr>
                            <td class="info font-bold text-center"><a href="javascript:;" style="font-size: 16px"
                                                                      id="xzandbankinfo">薪资及银行信息</a></td>
                        </tr>
                    </table>
                    <table class="table-bordered table" id="xzandbankinfoDiv" style="display: none;margin-bottom: 0">
                        <tr>
                            <td class="text-center">薪资级别</td>
                            <td>
                                <select name="salarylevel_id" id="salarylevel_id" class="form-control select">
                                    <option value="">请选择</option>
                                    {volist name="salarylevel" id="list"}
                                    <option value="{$list.id}">{$list.salaryLevel}</option>
                                    {/volist}
                                </select>
                            </td>
                            <td class="text-center">管理费(元/月)</td>
                            <td><input type="text" class="form-control 	validate[custom[number]]" id="manageMoney"
                                       name="manageMoney"></td>
                            <td class="text-center">保险(元/月)</td>
                            <td><input type="text" class="form-control 	validate[custom[number]]" name="safeMoney"
                                       id="safeMoney"></td>
                        </tr>
                        <tr>
                            <td class="text-center">杂费(元/月)</td>
                            <td><input type="text" class="form-control 	validate[custom[number]]" id="otherMoney"
                                       name="otherMoney"></td>
                            <td class="text-center">其他补贴(元/月)</td>
                            <td><input type="text" class="form-control 	validate[custom[number]]"
                                       name="otherSubsidyMoney"
                                       id="otherSubsidyMoney"></td>
                            <td class="text-center">开户行</td>
                            <td><input type="text" class="form-control" id="openingBank" name="openingBank" value=""></td>
                        </tr>
                        <tr>
                            <td class="text-center">银行账号</td>
                            <td colspan="5"><input type="text" maxlength="22"
                                                   class="form-control validate[custom[onlyNumberSp],minSize[18],maxSize[22]]"
                                                   id="bankAccount" name="bankAccount" value=""></td>
                        </tr>
                    </table>
                    <table class="table table-bordered">
                        <tr>
                            <td colspan="6" class="font-bold info">&nbsp;</td>
                        </tr>
                        <tr>
                            <td class="text-center">入职原因</td>
                            <td colspan="5">
                    <textarea name="entryReason" id="entryReason" style="width: 60%;height: 50px;resize: none;"
                              class="form-control"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">工牌照片</td>
                            <td style="padding: 1px">
                                <div style="height: 130px;width: 100px" class="form-group">
                                    <label for="workPhoto">
                                        <img src="__STATIC__/layout/img/nopic_boy.gif" id="workPhoto_img" alt="工牌上传"
                                             class="thumb"
                                             height="130" style="width:100px;">
                                    </label>
                                    <input type="file" class="upLoad" name="workPhoto" id="workPhoto"
                                           style="display: none;">
                                </div>
                                <a href="javascript:void (0);">工牌上传</a>&nbsp;
                                <a onclick="$('#workPhoto').val('');$('#workPhoto_img').attr('src','__STATIC__/layout/img/nopic_boy.gif');">清除</a>
                            </td>
                            <td class="text-center">身份证照片</td>
                            <td style="padding: 1px">
                                <div style="height: 120px;width: 100px" class="form-group">
                                    <label for="IDPhoto">
                                        <img src="__STATIC__/layout/img/nopic_boy.gif" id="IDPhoto_img" alt="身份证上传"
                                             class="thumb"
                                             height="130" style="width:100px;">
                                    </label>
                                    <input type="file" value="" class="upLoad" name="IDPhoto" id="IDPhoto"
                                           style="display: none;">
                                </div>
                                <a href="javascript:void (0);;">身份证上传</a>&nbsp;
                                <a onclick="$('#IDPhoto').val('');$('#IDPhoto_img').attr('src','__STATIC__/layout/img/nopic_boy.gif');">清除</a>
                            </td>
                            <td class="text-center">银行卡照片</td>
                            <td style="padding: 1px" colspan="2">
                                <div style="height: 120px;width: 100px" class="form-group">
                                    <input type="file" value="" class="upLoad" name="bankPhoto" id="bankPhoto"
                                           style="display: none;">
                                    <label for="bankPhoto">
                                        <img src="__STATIC__/layout/img/nopic_boy.gif" id="bankPhoto_img" alt="银行卡上传"
                                             class="thumb"
                                             height="130" style="width:100px;">
                                    </label>
                                </div>
                                <a href="javascript:void (0);;">银行卡上传</a>&nbsp;
                                <a onclick="$('#bankPhoto').val('');$('#bankPhoto_img').attr('src','__STATIC__/layout/img/nopic_boy.gif');">清除</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">备注</td>
                            <td colspan="5">
                    <textarea name="des" id="des" style="width: 60%;height: 50px;resize: none;"
                              class="form-control"></textarea>
                            </td>
                        </tr>
                    </table>
                    <div class="form-group white-bg" style="margin:20px 10px 20px 20px" id="upfileDiv">
                        <input type="hidden" id="exampleInputFile" name="exampleInputFile">
                        <input type="button" name="uploadify" value="" id="uploadify">
                        <div id="uploadifyQueue"></div>
                        <p class="help-block" style="color:#1295d2">注：最多上传15个文件，每个文件小于50M,支持格式：</p>
                        <p class="help-block" style="color:#1295d2">
                            jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav</p>
                    </div>

            </div>
            <div class="padding-10 text-center">
                <input type="hidden" name="isdraft" id="isdraft" value="">
                <input type="button" class="btn btn-primary" onclick="primary(0)" value="保存为草稿"/>
                <input type="button" class="btn btn-warning" onclick="primary(1)" value="保存并提交流程"/>
                <input type="button" class="btn btn-info" onclick="back()" value="返回"/>
            </div>
            </form>
        </div>
    </div>
</div>
<script>
    lay('.date').each(function () {
        laydate.render({
            elem: this
            , trigger: 'click'
        });
    });
    //关闭多选某一项
    $('body').on('click', '.duoxuan .close', function () {
        $(this).closest('.ren').remove()
    })
    $(document).on("click", ".netlist .close", function () {
        $(this).parent().remove();
    })


    $('#form_id').validationEngine('attach', {
        promptPosition: 'bottomRight'
    });

    function primary(type) {
        var enclosure_url = '';
        $('form').find('#uploadifyQueue .uploadifive-queue-item').each(function () {
            if ($(this).attr('uri')) {
                if (enclosure_url == '') {
                    enclosure_url += $(this).attr('uri');
                } else {
                    enclosure_url += "||" + $(this).attr('uri');
                }
            }
        });
        var otherNet_id = '';
        $('#selected_net .ren').each(function (idx, o) {
            if ($(this).data('id')) {
                if(otherNet_id == ''){
                    otherNet_id += $(this).data('id');
                }else{
                    otherNet_id += "," + $(this).data('id');
                }
            }
        })
        $('#exampleInputFile').val(enclosure_url);
        $('#otherNet_id').val(otherNet_id);
        $('#isdraft').val(type);
        // 获取下所有网点（50个）
            $('#form_id').submit();
    }

    function netTree(id) {
        //弹出选择网点框
        // $('#select_mainNet').on('click', function () {
        var index = layer.getFrameIndex(window.name)
        layer.open({
            type: 2,
            area: ['60%', '60%'],
            maxmin: true,
            content: '/index/ashippingguide/selectMainNet.html?index=' + index + '&id=' + id
        })
        return false
        // })
    }

    function net(id) {
        //网点补全
        $("#" + id).bsSuggest({
            url: "{:url('select/netjson2')}",
            effectiveFieldsAlias: {title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onSetSelectValue', function (e, re) {
            if (id == 'otherNet') {
                $('#' + id).val('');
                var bool = false;
                $('#selected_net .ren').each(function (idx, o) {
                    if ($(this).data('id') == re.id) {
                        bool = true;
                    }
                })
                if (bool == false) {
                    $('#selected_net').append('<span class="ren netlist" data-id="' + re.id + '">' + re.key + '<span class="close">×</span></span>')
                }
            } else {
                $('#' + id).val(re.key);
                $('#' + id + '_id').val(re.id);
            }
        });
    }


    //弹出选择品牌框
    $('#select_pinpai').on('click', function () {
        var index = layer.getFrameIndex(window.name)
        layer.open({
            type: 2,
            area: ['60%', '60%'],
            maxmin: true,
            content: '/index/ashippingguide/selectpinpai.html?index=' + index
        })
        return false
    })
    //产品品牌搜索自动补全
    $("#pinpai").bsSuggest({
        url: "/index/select/brandjson.html",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias: {title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $('#pinpai').val(keyword.key);
        $('#pinpai_id').val(keyword.id);
    });

    //弹出选择品类框
    $('#select_pinlei').on('click', function () {
        var index = layer.getFrameIndex(window.name)
        layer.open({
            type: 2,
            area: ['60%', '60%'],
            maxmin: true,
            content: '/index/ashippingguide/selectpinlei.html?index=' + index
        })
        return false
    })
    //产品品类搜索自动补全
    $("#pinlei").bsSuggest({
        url: "/index/select/categoryjson.html",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias: {title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $('#pinlei').val(keyword.key);
        $('#pinlei_id').val(keyword.id);
    });

    //销售人员搜索自动补全
    $("#referee").bsSuggest({
        url: "/index.php/index/apcaiwu/cnamejson",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias: {title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        console.log(keyword);
        $('#referee').val(keyword.key);
        $('#referee_id').val(keyword.id);
    });
    //弹出选择销售人树
    $('#selectreferee').click(function () {
        layer.open({
            type: 2,
            area: ['60%', '60%'],
            title: '销售人',
            maxmin: true,
            content: '/index.php/index/apcaiwu/selectCname',
            btn: ['确定', '关闭'],
            btnAlign: 'c',
            yes: function (i, o) {
                var id = $(o).find('iframe').contents().find('#renyuan').val()
                var name = $(o).find('iframe').contents().find('#renyuanname').val()
                if (id) {
                    $('#referee_id').val(name);
                    $('#referee_id_id').val(id);
                }
                layer.close(i)
            }
        });
        return false
    });
    $(document).ready(function () {

        if ($("#recordNov").val() == "") {
        }
    })

    var jieshou = $("#area_id");
    sousuo(jieshou);

    function sousuo(id) {
        id.bsSuggest({
            allowNoKeyword: false, //是否允许无关键字时请求数据
            multiWord: true, //以分隔符号分割的多关键字支持
            separator: ",", //多关键字支持时的分隔符，默认为空格
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            url: 'http://unionsug.baidu.com/su?p=3&t=' + (new Date()).getTime() + '&wd=',
            /*优先从url ajax 请求 json 帮助数据，注意最后一个参数为关键字请求参数*/
            jsonp: 'cb',
            /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
            processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                var i, len, data = {
                    value: []
                };
                if (!json || !json.s || json.s.length === 0) {
                    return false;
                }

                // console.log(json);
                len = json.s.length;

                jsonStr = "{'value':[";
                for (i = 0; i < len; i++) {
                    data.value.push({
                        word: json.s[i]
                    });
                }
                data.defaults = 'baidu';

                //字符串转化为 js 对象
                return data;
            }
        });

    }

    function back() {
        history.go(-1)
    }

    $("#moreinfo").click(function () {
        $("#moreinfoDiv").toggle()
    })
    $("#xzandbankinfo").click(function () {
        $("#xzandbankinfoDiv").toggle();
    })
</script>
{/block}